# 
#  kernel/Makefile 
#  
#  last modified at 2007.07.14 22:16 by ChenJie
#

# 目标
TARGET		= kernel.o
OBJS		= cpu.o \
		  fork.o \
		  time.o \
		  signal.o \
		  panic.o \
		  exception.o \
		  interrupt.o \
		  sched.o

# 工具及参数定义
CC		= gcc -march=i486
LD		= ld
AR		= ar
CPP		= gcc -E -nostdinc -I../include
CFLAGS		= -Wall -fno-stack-protector -finline-functions -nostdinc -I../include 
LDFLAGS		= -r

# CFLAGS 中不能加入-O 的优化参数，否则运行就会出现保护错误，不知道是何原因
# 定义隐式规则
.c.o:
	$(CC) $(CFLAGS)	-c -o $*.o $<
.S.o:
	$(CC) $(CFLAGS) -c -o $*.o $<
.c.s:					
	$(CC) $(CFLAGS) -S -o $*.s $<
.s.o:
	$(CC) $(CFLAGS) -c -o $*.o $<

# All Phony Targets
.PHONY : all clean dep

# Default starting position
all : $(TARGET)

$(TARGET) : $(OBJS) 
	$(LD) $(LDFLAGS) -o $(TARGET) $(OBJS)

clean :
	rm -f $(TARGET) $(OBJS)
#	(cd chr_drv; make clean)
#	(cd blk_drv; make clean)
#	(cd math; make clean)

dep:
	sed '/\#\#\# Dependencies/q' < Makefile > tmp_make
	(for i in *.c;do $(CPP) -M $$i;done) >> tmp_make
	cp tmp_make Makefile
	rm tmp_make
#	(cd chr_drv; make dep)
#	(cd blk_drv; make dep)
#	(cd math; make dep)

### Dependencies:
fork.o: fork.c ../include/clinux/kernel.h
panic.o: panic.c ../include/clinux/kernel.h ../include/asm/i386.h \
  ../include/clinux/config.h
sched.o: sched.c ../include/clinux/kernel.h ../include/clinux/sched.h \
  ../include/clinux/config.h ../include/clinux/mm.h \
  ../include/clinux/time.h ../include/asm/i8259.h ../include/asm/i386.h \
  ../include/asm/i8253.h
signal.o: signal.c
time.o: time.c ../include/asm/i386.h ../include/clinux/config.h \
  ../include/clinux/time.h ../include/clinux/kernel.h
trap.o: trap.c ../include/asm/i386.h ../include/clinux/config.h \
  ../include/clinux/kernel.h ../include/clinux/sched.h
